package controller;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import model.entity.role.Users;

public class AdminRoleContr extends HttpServlet {
	private static final long serialVersionUID = 1L;

	public AdminRoleContr() {
		super();
	}

	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		HttpSession session = request.getSession();
		Users user = (Users) session.getAttribute("user");
		if (user != null && user.getGroupRole().getRoleName().equals("Admin")){
			String command = request.getParameter("command");

			switch (command) {
			case "logOut":
				session.invalidate();
				response.sendRedirect("user_login.jsp");
				break;
			case "listBrand":
				
				response.sendRedirect("admin/listBrand.jsp");
				//request.getRequestDispatcher("./listBrand.jsp").forward(request, response);
				break;
			default:
				break;
			}
		}
	}

	protected void doPost(HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException {
	}

}
